$(function () {
    $('#submit-fpwd-btn').click(function (event) {
        event.preventDefault();

        var emailE = $('input[name="email"]');
        var captchaE = $('input[name="captcha"]');
        var passwordE = $('input[name="password"]');

        var email = emailE.val();
        var captcha = captchaE.val();
        var password = passwordE.val();

        if(!captcha||!password||!email){
            xtalert.alertInfo('请将数据填写完整！');
            return;
        }

        zlajax.post({
            'url': '/cms/fpwd/',
            'data': {
                'email': email,
                'captcha': captcha,
                'password': password
            },
            'success': function (data) {
                if (data['code'] == 200) {
                    xtalert.alertSuccessToast('密码修改成功！');
                    setTimeout(function () {
                        window.location = '/cms/login/';
                    }, 1000);
                } else {
                    xtalert.alertInfo(data['message']);
                }
            },
            'fail': function (error) {
                xtalert.alertNetworkError();
            }
        });
    });
});